package com.example.contacts;
 
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

public class SmgSqliteOpenHelper extends SQLiteOpenHelper {
	private String table_name;
	public SmgSqliteOpenHelper(Context context, String name,
			CursorFactory factory, int version) {
		super(context, name, factory, version);
		Log.e("SMGlog","constructor");
		this.table_name= name;
		// TODO Auto-generated constructor stub
	}

	@Override
	public void onCreate(SQLiteDatabase arg0) {
		// TODO Auto-generated method stub
		//arg0.execSQL("DROP TABLE "+table_name+";");
		String createSQL="CREATE TABLE "+table_name+" (id varchar(20) identity(1,1) not null primary (key), name varchar(20), phone varchar(20), group INT);";
		Log.e("SMGlog",createSQL);
		//arg0.execSQL("DROP TABLE Contacts IF EXISTS");
		
		arg0.execSQL(createSQL);
		Log.e("SMGlog","1");
		arg0.execSQL("CREATE TABLE phones (id varchar(20) identity(1,1) not null primary key, phone varchar(20))");
		Log.e("SMGlog","2");
		arg0.execSQL("CREATE TABLE Group (Groupid int identity(1,1) not null primary key, Groupname varchar(20));");
		Log.e("SMGlog","3");
	}

	@Override
	public void onUpgrade(SQLiteDatabase arg0, int arg1, int arg2) {
		// TODO Auto-generated method stub

	}

}
